package com.xuan.ifelse.mall.service.strategy;

import com.xuan.ifelse.anno.ElectronicType;
import com.xuan.ifelse.constant.ElectronicEnum;
import com.xuan.ifelse.exp.BusException;
import com.xuan.ifelse.mall.service.ElectronicProductService;
import com.xuan.ifelse.mall.service.vo.OrderVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xuan
 * @version 1.0.0
 * @Description 电子商品业务策略
 * @createTime 2022年01月02日 15:06
 */
@Slf4j
@Primary
@Component
public class ElectronicProductServiceStrategy implements ElectronicProductService {

    /**
     * 打折
     * @param type
     * @return
     */
    @Override
    public String discount(String type) {
        ElectronicProductService electronicProductService=ElectronicProductServiceFactory.getElectronicProductServiceImpl(type);
        return electronicProductService.discount("这是参数");

    }

    /**
     * 满减
     * @param orderVo 业务参数
     * @return
     */
    @Override
    public OrderVo fullReduction(OrderVo orderVo) {
        ElectronicProductService electronicProductService=ElectronicProductServiceFactory.getElectronicProductServiceImpl(orderVo.getType());
        return electronicProductService.fullReduction(orderVo);
    }


}
